﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Model
{
    [DataContract]
    public class Sale
    {
        [DataMember]
        private int id;
        [DataMember]
        private byte paid;
        [DataMember]
        private int orderNr;
        [DataMember]
        private Event even;
        [DataMember]
        private int quantity;
        [DataMember]
        private double discount;
        [DataMember]
        private byte discountProcent;

        //private List<SalesLineItem> items;

        public Sale(int id, int orderNr, byte paid, Event even, int quantity, double discount, byte discountProcent)
        {
            Id = id;
            Paid = paid;
            OrderNr = orderNr;
            Event = even;
            Quantity = quantity;
            Discount = discount;
            DiscountProcent = discountProcent;
        }

        public Sale()
        {
            //items = new List<SalesLineItem>();
        }

        [DataMember]
        public int Id
        {
            get { return this.id; }
            set { id = value; }
        }

        [DataMember]
        public int OrderNr
        {
            get { return this.orderNr; }
            set { this.orderNr = value; }
        }

        [DataMember]
        public double Total
        {
            get
            {
                if (DiscountProcent == 0)
                {
                    return Event.Price - Discount;
                }
                else
                {
                    double minus = Event.Price * Discount /100;
                    return Event.Price - minus;
                }
               
            }
        }

        [DataMember]
        public byte Paid
        {
            get { return this.paid; }
            set { this.paid = value; }
        }

        [DataMember]
        public Event Event
        {
            get { return even; }
            set { even = value; }
        }

        [DataMember]
        public int Quantity
        {
            get { return quantity; }
            set { quantity = value; }
        }

        [DataMember]
        public double Discount
        {
            get { return this.discount; }
            set { this.discount = value; }
        }

        [DataMember]
        public byte DiscountProcent
        {
            get { return this.discountProcent; }
            set { this.discountProcent = value; }
        }

        //public void AddSalesLine(SalesLineItem item)
        //{
        //    items.Add(item);
        //}

        //public List<SalesLineItem> GetSaleLineItems()
        //{
        //    return items;
        //}
    }
}
